<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="/asset/jQuery/jquery-3.3.1.js"></script>
<title>Insert title here</title>
</head>
<body>
<div align="center">
<input type="text" placeholder="请输入用户名" id="username"><br>
<input type="password" placeholder="请输入密码" id="password"><br>
<input type="button" value="登陆" id="submit"><br>
<a href="/module/login/reg.html">没有账号？点击这里进行注册</a>
</div>
<script>
$(document).ready(function(){
	$("#submit").click(function(){
		var username=$("#username").val();
		var password=$("#password").val();
		$.ajax({
			url:"/login",
			type:"post",
			async:true,
			data:{
				"username":username,
				"password":password
			},
			dataType:"json",
			success:function(data){
				if(data.success){
					location.href="/index";
				}else{
					alert(data.message);
				}
			}
			
		})
	})
})
</script>
</body>
</html>